package dimension;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @ Auther: o2o-rd-0008
 * @ Date:   2020/9/22 17:32
 * @ Param:  ${PARAM}
 * @ Description:
 */
public class DimensionDeal {


    public static void main(String[] args) {

    }


    public static void addressMatch(){

        Connection connection = GetConnection("sysadmin", "Bigdata@123");

        StringBuilder sb = new StringBuilder();

        sb.append("");
        sb.append("");
        sb.append("");
        sb.append("");
        sb.append("");
        sb.append("");

        PreparedStatement statement = null;
        try {

            statement = connection.prepareStatement(sb.toString());

            statement.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (statement != null){
                try {
                    statement.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if (connection != null){
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }

    }



    /**
     * 数据库连接
     *
     * @param username
     * @param passwd
     * @return
     */
    public static Connection GetConnection(String username, String passwd) {
        String driver = "org.postgresql.Driver";
//        String sourceURL = "jdbc:postgresql://192.168.2.148:8000/postgres";
        String sourceURL = "jdbc:postgresql://192.168.2.234:8000/postgres";
        Connection conn = null;
        try {
            //加载数据库驱动。
            Class.forName(driver).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        try {
            //创建数据库连接。
            conn = DriverManager.getConnection(sourceURL, username, passwd);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return conn;
    }


}
